<template>
  <div class="contact">
    <section class="contact-header">
      <h1>联系我</h1>
      <p>如果您有任何问题或合作机会，请随时与我联系</p>
    </section>
    
    <div class="contact-content">
      <div class="contact-info">
        <div class="info-item" v-for="item in contactInfo" :key="item.type">
          <div class="info-icon">
            <i :class="item.icon"></i>
          </div>
          <div class="info-details">
            <h3 v-text="item.type"></h3>
            <p v-text="item.value"></p>
          </div>
        </div>
      </div>
      
      <div class="contact-form">
        <form @submit.prevent="sendMessage">
          <div class="form-group">
            <input 
              type="text" 
              v-model="form.name" 
              placeholder="您的姓名" 
              required
            >
          </div>
          
          <div class="form-group">
            <input 
              type="email" 
              v-model="form.email" 
              placeholder="您的邮箱" 
              required
            >
          </div>
          
          <div class="form-group">
            <textarea 
              v-model="form.message" 
              placeholder="您的消息" 
              rows="6" 
              required
            ></textarea>
          </div>
          
          <button type="submit" class="btn btn-primary">发送消息</button>
        </form>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const contactInfo = ref([
  {
    type: '邮箱',
    value: 'zhangyichuang@example.com',
    icon: '📧'
  },
  {
    type: '电话',
    value: '+86 138 0013 8000',
    icon: '📱'
  },
  {
    type: '地址',
    value: '上海市黄浦区南京东路123号',
    icon: '📍'
  }
])

const form = ref({
  name: '',
  email: '',
  message: ''
})

const sendMessage = () => {
  // 这里可以添加发送消息的逻辑
  console.log('发送消息:', form.value)
  alert(`感谢您的消息，${form.value.name}！我会尽快回复您。`)
  
  // 重置表单
  form.value = {
    name: '',
    email: '',
    message: ''
  }
}
</script>

<style scoped>
.contact {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.contact-header {
  text-align: center;
  margin-bottom: 50px;
}

.contact-header h1 {
  font-size: 2.5rem;
  margin-bottom: 20px;
  color: #333;
}

.contact-header p {
  font-size: 1.2rem;
  color: #666;
  max-width: 600px;
  margin: 0 auto;
}

.contact-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
}

@media (max-width: 768px) {
  .contact-content {
    grid-template-columns: 1fr;
  }
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 25px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.info-icon {
  font-size: 2rem;
}

.info-details h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: #333;
}

.info-details p {
  font-size: 1.1rem;
  color: #666;
}

.contact-form {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.form-group {
  margin-bottom: 25px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 15px;
  border: 2px solid #eee;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #42b983;
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.btn {
  padding: 15px 30px;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, #42b983, #359c6d);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(66, 185, 131, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}
</style>